package de.fu_berlin.minesweeper;

import java.util.Random;

/**
 * TASK 4a
 */
public class Player implements GameListener{
	private Field gameField;
	private int intPoints; 	// points, if < 0: player lost
	private String strName;
	private static Random objRnd = new Random();
	
	public Player(String strName){
		this.intPoints = 0;
		this.gameField = new Field(16,16,0.25f);
		this.gameField.addGameListener(this);
		this.strName = strName;
	}
	/**
	 * Gets the name of the current player instance
	 * @return String value
	 */
	public String getName(){
		return this.strName;
	}
	
	/**
	 * Play Minesweeper
	 */
	public void play(){
		while (this.gameField.getRemainingFields() > 0){
			this.intPoints += this.gameField.chooseField(Player.objRnd.nextInt(16),
														 Player.objRnd.nextInt(16));
		}
	}
	
	@Override
	public void gameWon(){
		// empty
		
	}
	
	@Override
	public void gameOver(){
		// empty
	}
	
	/**
	 * Gets the points of the current player instance
	 * @return integer value
	 */
	public int getPoints(){
		return this.intPoints;
	}
	
	@Override
	public void remainingFieldsChanged(int intRemaining){
		// empty
	}
	
	@Override
	public void gainedPoints(int newPoints){
		// empty
	}
}